Add a more convenient way to dump
authorMatthias Clasen <mclasen@redhat.com>
Sun, 19 Jun 2011 17:20:32 +0000 (13:20 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:07:58 +0000 (16:07 -0400)
For initial creation of the results, allow to run
accessibility-dump --generate file.ui,
which will dump just the expected output to stdout,
without any extra decorations.

tests/a11y/accessibility-dump.c

index 0d97f1aedd367692e5da4fac4b9062961b96188c..c3054d910e2e51b20b4b570da9f315673df6b932 100644 (file)
@@ -295,6 +295,22 @@ dump_ui_file (const char *ui_file,
   gtk_widget_destroy (window);
 }
 
+static void
+dump_to_stdout (GFile *file)
+{
+  char *ui_file;
+  GString *dump;
+
+  ui_file = g_file_get_path (file);
+  dump = g_string_new ("");
+
+  dump_ui_file (ui_file, dump);
+  g_print ("%s", dump->str);
+
+  g_string_free (dump, TRUE);
+  g_free (ui_file);
+}
+
 static void
 test_ui_file (GFile *file)
 {
@@ -420,6 +436,16 @@ main (int argc, char **argv)
 
       g_object_unref (dir);
     }
+  else if (argc == 3 && strcmp (argv[1], "--generate") == 0)
+    {
+      GFile *file = g_file_new_for_commandline_arg (argv[2]);
+
+      dump_to_stdout (file);
+
+      g_object_unref (file);
+
+      return 0;
+    }
   else
     {
       guint i;